package com.rxyb.authority.gateway.controller;


import com.rxyb.authority.gateway.dto.menu.*;
import com.rxyb.authority.service.OpsAuthorityMenuService;
import com.rxyb.core.respone.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author DUYH
 * @since 2020-05-29
 */
@RestController
@RequestMapping(value = "/menu", produces = {MediaType.APPLICATION_JSON_UTF8_VALUE})
public class OpsAuthorityMenuController {

    @Autowired
    private OpsAuthorityMenuService opsAuthorityMenuService;

    /**
     * 创建
     *
     * @author duyh
     */
    @PostMapping(value = "create", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public R<CreateMenuRsp> create(@Validated @RequestBody CreateMenuReq createMenuReq) {
        return opsAuthorityMenuService.create(createMenuReq);
    }

    /**
     * 删除
     *
     * @author duyh
     */
    @PostMapping(value = "remove", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public R<DeleteMenuRsp> remove(@Validated @RequestBody DeleteMenuReq deleteMenuReq) {
        return opsAuthorityMenuService.remove(deleteMenuReq);
    }

    /**
     * 修改
     *
     * @author duyh
     */
    @PostMapping(value = "update", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public R<UpdateMenuRsp> update(@Validated @RequestBody UpdateMenuReq updateMenuReq) {
        return opsAuthorityMenuService.update(updateMenuReq);
    }

    /**
     * 列表
     *
     * @author duyh
     */
    @PostMapping(value = "list", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public R<GetMenuListRsp> list(@Validated @RequestBody GetMenuListReq getMenuListReq) {
        return opsAuthorityMenuService.list(getMenuListReq);
    }

    /**
     * 树形菜单
     *
     * @author duyh
     */
    @PostMapping(value = "tree", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public R<GetRoleMenuListRsp> tree(@Validated @RequestBody GetRoleMenuListReq getRoleMenuListReq) {
        return opsAuthorityMenuService.tree(getRoleMenuListReq);
    }
}
